/*
	Copyright (c) 2009, SpLib.net
  	All rights reserved.
  	
  	Author:6spring
  	About:网络消息
*/

package SpLib.Net
{
	import SpLib.Com.Com;

	public class NetMsg
	{
		public static const TYPE_HAND:int = 1;	//连接握手
		public static const TYPE_HAND_RESP:int = 2;	//连接握手返回
		public static const TYPE_PING:int = 3;	//保持连接的心跳，可以作为ping
		public static const TYPE_TRANSFERLIST:int = 4;	//获取中转服务器列表
		public static const TYPE_RPC:int = 5;	//RPC调用
		public static const TYPE_RPC_RESP:int = 6;	//RPC调用返回
		public static const TYPE_BOARDCAST:int = 7;	//服务广播消息
		public static const TYPE_SESSION_JOIN:int = 8;	//加入组消息
		public static const TYPE_SESSION_JOIN_RESP:int = 9;	//加入组结果返回消息
		public static const TYPE_SESION_SENDS:int = 10;	//给组内服务器端控制对象发消息ToS
		public static const TYPE_SESSION_SENDC:int = 11;	//服务组内对象给客户端推送消息ToC
		public static const TYPE_MIRROR_CREATE:int = 12;	//创建组内其他玩家的镜像对象
		public static const TYPE_MIRROR_DESTROY:int = 13;	//删除组内其他玩家的镜像对象
		public static const TYPE_SESSION_LEAVE:int = 14;	//离开组
		public static const TYPE_BREAKPLAYER:int = 15;		//踢用户
		public static const TYPE_SERVICEBREAK:int = 16;		//服务断开
		public static const TYPE_SERVERPUSH:int = 17;		//系统推送
		public static const TYPE_P2PDATA:int = 18;			//P2P消息
		
		public static const TYPE_TRACE:int = 0x7FFFFFFF;//远程调试信息输出
				
		public var m_nMsgtype:int;									//消息类型
		public var m_nEveID:int = 0;								//消息ID
		public var m_Address:SpLib.Net.GNID = new SpLib.Net.GNID;	//消息地址
		public var m_Value:Array = new Array;						//消息数据
		public var m_GLID:SpLib.Net.GLID = new SpLib.Net.GLID;		//socket标识源
		
		public var m_sSName:String = "";				//目标服务名
		public var m_sGName:String = "";				//目标网络组名
		public var m_sEveName:String = "";				//消息名
		
		public function NetMsg()
		{
		}
		
		public function ClearData():void
		{
			m_nEveID = 0;
			m_Address.Clear();
			m_Value = [];
			m_GLID.Clear();
			
			m_sSName = "";
			m_sGName = "";
			m_sEveName = "";
		}
		
		public function MakeKey():void
		{
			if(m_sSName.length!=0)
			{
				m_Address.m_nServiceID = SpLib.Com.Str2Key(m_sSName);
			}
			
			if(m_sGName.length!=0)
			{
				m_Address.m_nGroupID = SpLib.Com.Str2Key(m_sGName);
			}
			
			if(m_sEveName.length!=0)
			{
				m_nEveID = SpLib.Com.Str2Key(m_sEveName);
			}
		}
	}
}